SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[usp_UpdateEmailSign]
	
	(
	@param_id int,
	@param_Admin_LoginID VarChar(50),
	@param_name VarChar(50),
	@param_contents Varchar(max),
	@param_is_default bit,
	@param_update_time smalldatetime,
	@param_user_update VarChar(50)
	)
	
AS
	/* SET NOCOUNT ON */
	 DECLARE @Count INT
                 SET @Count = (
                        SELECT   COUNT(*)
                        FROM     dbo.JOL_EmailManagement_Sign
                        WHERE    Admin_LoginID = @param_Admin_LoginID and id <>@param_id and name=@param_name
                        )
                IF @Count = 0 
					update dbo.JOL_EmailManagement_Sign set name=@param_name,contents=@param_contents,is_default=@param_is_default,update_time=@param_update_time,user_update=@param_user_update
					where id=@param_id
                
					IF @param_is_default='TRUE'
						update dbo.JOL_EmailManagement_Sign 
						set is_default='false' where Admin_LoginID=@param_Admin_LoginID and  is_default='TRUE' and name<>@param_name
					
					
                    
                   
                ELSE
	
				 SELECT  '该签名已存在'
                    
	RETURN
GO
